#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main()
{
  int fd=open("log.txt",O_CREAT|O_WRONLY|O_TRUNC,0666);
  dup2(fd,1);
  printf("hello fd:%d\n",fd);
  fputs("hello fd\n",stdout);;
  fprintf(stdout,"hello fd:%d\n",fd);
  const char*str="hello fd\n";
  fwrite(str,1,strlen(str),stdout);
  return 0;
}
